package com.linkoog.devtools.code_generator.common;

import com.intellij.openapi.util.IconLoader;
import com.intellij.util.xml.NamedEnum;

import javax.swing.*;

public enum JavaType implements NamedEnum {
    OBJECT("Object", null, IconLoader.getIcon("/icons/data-type/object.svg")),
    LIST("List", "java.util.List",IconLoader.getIcon("/icons/data-type/array.svg")),

    BOOLEAN("Boolean", null, IconLoader.getIcon("/icons/data-type/boolean.svg")),

    BYTE("Byte", null, IconLoader.getIcon("/icons/data-type/number.svg")),
    SHORT("Short", null, IconLoader.getIcon("/icons/data-type/number.svg")),
    INTEGER("Integer", null, IconLoader.getIcon("/icons/data-type/number.svg")),
    LONG("Long", null, IconLoader.getIcon("/icons/data-type/number.svg")),

    FLOAT("Float", null, IconLoader.getIcon("/icons/data-type/number.svg")),
    DOUBLE("Double", null, IconLoader.getIcon("/icons/data-type/number.svg")),
    BIGDECIMAL("BigDecimal", "java.math.BigDecimal", IconLoader.getIcon("/icons/data-type/number.svg")),

    STRING("String", null, IconLoader.getIcon("/icons/data-type/string.svg")),
    DATE("Date", "java.util.Date", IconLoader.getIcon("/icons/data-type/date.svg"))
    ;

    private String name;
    private String fullName;
    private Icon icon;

    private JavaType(String name, String fullName, Icon icon){
        this.name = name;
        this.fullName = fullName;
        this.icon = icon;
    }

    public String getName() {
        return name;
    }

    public String getFullName(){
        return fullName;
    }

    public Icon getIcon() {
        return icon;
    }

    @Override
    public String getValue() {
        return name;
    }

    public static JavaType valueOfName(String name){
        for (JavaType dataType : JavaType.values()) {
            if (dataType.getName().equals(name)){
                return dataType;
            }
        }
        return null;
    }


}
